
/* Model estimation: basic NK model */
/* By Toshihiro OKADA */



@#define prc_index=0
///////////////////////////////////////////////////////////////
//* =0: No indexization, = 1: With indexization *// 
/////////////////////////////////// ////////////////////////////
 
@#define news=1 
@#define dshock=0
@#define cshock=1
@#define hshock=1
@#define de_shock=0
@#define ce_shock=0
@#define che_shock=1
//* de_shock =1 : demand shock (general preference), teck shock, interest shock & news shock (1-4 periods) 

@#define myshock=0
//** Not used **//

@#define exp_shock=4
@#define ttb_spec=8
@#define eshock=16

@#define romer=0
//** Not used **//

////// Line specification for figures ///////
lsp =1; /* setting a line specification for figures: 1='-', 2='--', 3=':' and 4='-.' */

@#define tech =0
/////////////////////////////////////////////////////////////////////////////////
//* tech=1: endogenous A, type=0: no A                                 *// 
///////////////////////////////////////////////////////////////////////////////

@#define shkm =0
@#define shki =1
@#define shku =1
@#define shkue =1
@#define shkud =1
@#define shkuc =1
@#define shkuh =1
@#define shkum =0

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//* shkm=1: money growth shock is ON, shki=1: interest rate shock is ON,  shku=1: tech shock is ON, shkud=1: preference shock is ON, shkue =1: news shock*// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@#define unrealized =0
//** Not used **//


@#if tech==0
var y_g, c_g, h_g, iv_g, w_g, tfp_g,tfpe_g, k_g, gg, ggn, uf, pai,y,tfp,tfpe, tfpn,c,k,iv,h,w,r,prc,ppai,m,i,lamda,u,ud,v,pain,yn,kn,ivn,hn,cn,wn,rn,pn,in,lamdan,yg,hg,fpai,gap,uc, uh, um,ynobs, tq,tqn, mc,mcn;
//var  pai,y,c,k,iv,h,w,r,p,ppai,m,i,lamda,u,ud,v,pain,yn,kn,ivn,hn,cn,wn,rn,pn,in,lamdan,yg,hg,fpai,gap,uc,um,uh, ynobs, tq;
   
  @#if eshock==16
  varexo ei eu euc euh ef eue4 eue8 eue12 eue etfp;
  @#endif 
  @#if eshock==20
  varexo ei eu euc euh eue1 eue2 eue3 eue4 eue5 eue6 eue7 eue8 eue9 eue10 eue11 eue12 eue13 eue14 eue15  eue16 eue17 eue18 eue19 eue;
  @#endif
  
@#endif

@#if tech==0
// parameters hb  xxx, rhoi,xpai, xy, gamma, delta, phi, theta, rho, rhom,rhouc,rhouh, rhou,rhoud, sigc, sigh, sigm, ss;
 parameters tau, hb,  xxx, rhoi,xpai, xy, gamma, delta, phi, theta, rho, rhoum,rhouc,rhouh, rhou,rhoud,rhouf, sigc, sigh, sigm, ss;

@#endif


@#if tech==0
 //index=0.5;
 hb=0.75; % Internal habit formation param.
 gamma = 0.99; % discount factor  
 delta =  0.10000000/4; %capital depreciation rate

 ss=4.000000001; % the second derivatives of adjustment cost: CEE=2.48, Rebello=1.3, Christiano et al (CLMR),  Nutahara =15.1 and Fujwara=2.48 (no adjustment cost: ss=0).
 sigc = 1.00; % 1.0, Smet=1.613 *** Need a high value to hump shaped response of i shock
 sigh =2.00; % 0.1 or 1(CHristiano, handbook),Smet=1.265 
 sigm =  2.56; % CLE=9
 
 xxx = 0.75; %  0.8 vartheta in the paper: CLE=0.8
 xpai = 1.5; % 1.5 varpi_pai in the paper: 1.5 (CLE&Gali)
 xy =0.125; % 0.125 varpi_y in the paper: 0.5/4 (gali), 0.1 (CLE) 


 rhoi = 0.500; % interest rate (rule) shock: 0.5 (Gali) &0.15(Smet)
 rhoum = 0.0;  % money growth (rulr) shock:
 rhou = 0.40; % technology shock

 rhoud = 0.90; % preference shock: this needs to  high to get good results
 rhouc = 0.520; % preference shock: this needs to  high to get good results
 rhouh = 0.540; % preference shock: this needs to  high to get good results
 rhouf = 0.24;
 
 phi =4.0; % the parameter related to markup rate (4.33) *.*.* 
 theta = 0.33; % capital share
 rho = 0.750000; % price stickness: 0.75 (conventional value) & rho =0 for flexible price

 epsilon = 0.1/4; % R&D success probability: Comin & Gertler (0.1 per year)
 gammaa = 0.750; % 0.15 technology spillover effect (Romer type R&D spec): gamma<0 for "Shoulders of a Giant" effect & gamma>0 for "Steping Toes" effect 
 alfa = 0.25; % 1/(1+alfa) = elastilicity of R&D, Bransetter (0.25). This para affect hours response to productivity shocks
 psi = 1-(0.1000000/4); % survival rate of A: 0.005 per year of tech. depreciation is conventional value. psi is important para for expectation shock
 tau=0.18;

@#endif


model(linear);


@#if tech==0  

#iss = (1/gamma)-1;
#rss = iss + delta; 
#wss = (((phi-1)/phi)*(1-theta)*(((1-theta)/theta)^(-theta))*(rss^(-theta)))^(1/(1-theta));
#yss_hss = ((theta/(1-theta))*(wss/rss))^theta;
#kss_hss = (yss_hss)^(1/theta);
#css_hss = yss_hss - delta*kss_hss - tau*yss_hss;
#hss = (wss*(css_hss^(-sigc))*((1-hb)^(-sigc))*(1-hb*gamma))^(1/(sigh+sigc));
#yss = (((theta/(1-theta))*(wss/rss))^theta)*hss;
#kss = (yss_hss^(1/theta))*hss;
#css = css_hss*hss;
#mss = (((1-hb)*css)^(sigc/sigm))*(((1+iss)/iss)^(1/sigm))*((1-hb*gamma)^(-1/sigm));
#ivss = delta*kss;
#lamdass = (1-hb*gamma)*((1-hb)*css)^(-sigc);
#ggss =tau*yss; % ggss=staedy state value of gg, govt expnditure
@#endif

////////////////////////////
// Baseline, no tech model //
////////////////////////////
@#if tech==0
c-hb*c(-1)= (1+gamma*hb)*(c(+1)-hb*c) - gamma*hb*(c(+2)-hb*c(+1)) - ((1-hb)/sigc)*(1-gamma*hb)*((iss/(1+iss))*(1/iss)*i + prc - prc(+1) + uc(+1) + ud(+1)) + ((1-hb)/sigc)*(uc + ud + gamma*hb*(uc(+2) +ud(+2))) ; 
sigh*h = w - uh + (1/(1-hb*gamma))*( (-sigc/(1-hb))*(c - hb*c(-1)) + uc ) + (hb*gamma/(1-hb*gamma))*( (sigc/(1-hb))*(c(+1)-hb*c) - uc(+1) - ud(+1) +ud );
sigm*(m-prc) = (-1/(1+iss))*(1/iss)*i + um + (1/(1-hb*gamma))*( (sigc/(1-hb))*(c-hb*c(-1)) -uc + (hb*gamma)*( (-sigc/(1-hb))*(c(+1)-hb*c) + uc(+1) +ud(+1) - ud) );
lamda = (1-delta)*gamma*lamda(+1) - ((1-(1-delta)*gamma)/(1-hb*gamma))*( (sigc/(1-hb))*(c(+1)-hb*c) - (1/rss)*r(+1) - uc(+1) - ud(+1) - hb*gamma*( (sigc/(1-hb))*(c(+2)-hb*c(+1)) - (1/rss)*r(+1) -uc(+2) -ud(+2) ) );
iv =  (gamma/(1+gamma))*iv(+1) + (1/(1+gamma))*iv(-1) + (1/(ss*(1+gamma)))*lamda  + (1/(ss*(1+gamma)*(1-hb*gamma)))*( (sigc/(1-hb))*(c-hb*c(-1)) - uc - ud +gamma*hb*( (-sigc/(1-hb))*(c(+1)-hb*c) + uc(+1) +ud(+1) ) ) ;


yss*y = css*c + ivss*iv +ggss*gg;
(1-delta)*k(-1) +delta*iv - k = 0;

y = u + theta*k(-1) + (1-theta)*h;
h - k(-1) - (1/rss)*r + w = 0;

@#if prc_index==0
pai = gamma*(pai(+1)) + (((1-gamma*rho)*(1-rho))/(rho))*(-u + theta*(1/rss)*r +(1-theta)*w ) ;
@#endif
@#if prc_index==1
pai = ( gamma/(1+gamma*rho*index) )*(pai(+1)) + ( index/(1+gamma*rho*index) )*pai(-1)+ (  ((1-gamma*rho)*(1-rho))/( (rho)*(1+gamma*rho*index) )  )*(-u + theta*(1/rss)*r +(1-theta)*w ); 
@#endif

pai = prc - prc(-1);

tq=lamda-(1/(1-gamma*hb))*( (sigc/(1-hb))*(-c+hb*c(-1))+uc+ud - gamma*hb*( (sigc/(1-hb))*(-c(+1)+hb*c) + uc(+1)+ud(+1) ) );
mc=(-u + theta*(1/rss)*r +(1-theta)*w );
tfp=u;

tfpe=0.9999*tfpe(-1) + tfp_g + etfp;

gg=(1/tau)*uf +y; // * govt expenditure

/////////////////////////////////////////////////////////////
// Monetary Policy (Inerest rate rule) & interest rate shock //
//////////////////////////////////////////////////////////////
iss*(1/iss)*i = ((1+iss)^(xxx))*(xxx*(iss/(1+iss))*(1/iss)*i(-1) + (1-xxx)*((xpai)*(pai)+(xy)*(yg)) + v);

v = rhoi*v(-1) + ei;
uf = rhouf*uf(-1)+ef;

// Technology & news shocks //
@#if exp_shock==4
 @#if news==1
      @#if eshock==16
   //u = rhou*u(-1) +eu + eue1(-1) + eue2(-2) + eue3(-3) +eue4(-4)+eue5(-5)+eue6(-6)+eue7(-7)+eue8(-8)+eue9(-9)+eue10(-10)+eue11(-11)+eue12(-12)+eue13(-13)+eue14(-14)+eue15(-15)+eue(-16); 
   u = rhou*u(-1) +eu + eue4(-4)+eue8(-8)+eue12(-12)+eue(-16); 
   @#endif 
   @#if eshock==20
   u = rhou*u(-1) +eu + eue1(-1) + eue2(-2) + eue3(-3) +eue4(-4)+eue5(-5)+eue6(-6)+eue7(-7)+eue8(-8)+eue9(-9)+eue10(-10)+eue11(-11)+eue12(-12)+eue13(-13)+eue14(-14)+eue15(-15)+eue16(-16)+eue17(-17)+eue18(-18)+eue19(-19)+eue(-16); 
   @#endif
  @#endif
 @#if news==0
   u = rhou*u(-1) +eu ; 
 @#endif
@#endif
 
////////////////////////
// Preference shocks //
//////////////////////
@#if dshock==1
ud = rhoud*ud(-1) +eud; //* Preference shock
@#endif

@#if dshock==0
ud = rhoud*ud(-1); //* Preference shock
@#endif

@#if cshock==1
uc = rhouc*uc(-1) +euc; //* Preference shock
@#endif

@#if cshock==0
uc = rhouc*uc(-1); //* Preference shock
@#endif


@#if hshock==1
uh = rhouh*uh(-1) +euh; //* Preference shock
@#endif

@#if hshock==0
uh = rhouh*uh(-1); //* Preference shock
@#endif


//um = rhoum*um(-1) +eum; //* Preference shock
um = rhoum*um(-1) ; //* Preference shock


//yg=y-yn; //* gdp gap
yg=y-ynobs; //* gdp gap with measurement errors
hg = h-hn;


gap=(-u + theta*(1/rss)*r +(1-theta)*w );
//gap_nw=(-u + theta*(1/rss)*r +(1-theta)*w );
fpai = pai(+1);
ppai = pai(-1);


y_g=y-y(-1); //*growth rate
c_g=c-c(-1);
h_g=h-h(-1);
iv_g=iv-iv(-1);
w_g=w-w(-1);
tfp_g =tfp-tfp(-1);
tfpe_g=tfp_g + etfp;

k_g=k-k(-1);


//////////////////////////
//* natural variables *//
////////////////////////


cn-hb*cn(-1)= (1+gamma*hb)*(cn(+1)-hb*cn) - gamma*hb*(cn(+2)-hb*cn(+1)) - ((1-hb)/sigc)*(1-gamma*hb)*((iss/(1+iss))*(1/iss)*in + pn - pn(+1) + uc(+1) + ud(+1)) + ((1-hb)/sigc)*(uc + ud + gamma*hb*(uc(+2) +ud(+2))) ; 
sigh*hn = wn - uh + (1/(1-hb*gamma))*( (-sigc/(1-hb))*(cn - hb*cn(-1)) + uc ) + (hb*gamma/(1-hb*gamma))*( (sigc/(1-hb))*(cn(+1)-hb*cn) - uc(+1) - ud(+1) +ud );
//sigm*(mn-pn) = (-1/(1+iss))*(1/iss)*in + um + (1/(1-hb*gamma))*( (sigc/(1-hb))*(cn-hb*cn(-1)) -uc + (hb*gamma)*( (-sigc/(1-hb))*(cn(+1)-hb*cn) + uc(+1) +ud(+1) - ud) );
sigm*(0-pn) = (-1/(1+iss))*(1/iss)*in + um + (1/(1-hb*gamma))*( (sigc/(1-hb))*(cn-hb*cn(-1)) -uc + (hb*gamma)*( (-sigc/(1-hb))*(cn(+1)-hb*cn) + uc(+1) +ud(+1) - ud) );

lamdan = (1-delta)*gamma*lamdan(+1) - ((1-(1-delta)*gamma)/(1-hb*gamma))*( (sigc/(1-hb))*(cn(+1)-hb*cn) - (1/rss)*rn(+1) - uc(+1) - ud(+1) - hb*gamma*( (sigc/(1-hb))*(cn(+2)-hb*cn(+1)) - (1/rss)*rn(+1) -uc(+2) -ud(+2) ) );
ivn =  (gamma/(1+gamma))*ivn(+1) + (1/(1+gamma))*ivn(-1) + (1/(ss*(1+gamma)))*lamdan  + (1/(ss*(1+gamma)*(1-hb*gamma)))*( (sigc/(1-hb))*(cn-hb*cn(-1)) - uc - ud +gamma*hb*( (-sigc/(1-hb))*(cn(+1)-hb*cn) + uc(+1) +ud(+1) ) ) ;

 yss*yn = css*cn + ivss*ivn + ggss*ggn;
(1-delta)*kn(-1) +delta*ivn - kn = 0;
ynobs=yn;

hn - kn(-1) - (1/rss)*rn + wn = 0;
yn = u + theta*kn(-1) + (1-theta)*hn;
0 = (((1-gamma*0)*(1-0)))*(-u + theta*(1/rss)*rn +(1-theta)*wn ) ;

pain = pn - pn(-1);
//mn = mn(-1);
//mn = 0;

tfpn=u;
tqn=lamdan-(1/(1-gamma*hb))*( (sigc/(1-hb))*(-cn+hb*cn(-1))+uc+ud - gamma*hb*( (sigc/(1-hb))*(-cn(+1)+hb*cn) + uc(+1)+ud(+1) ) );
mcn=(-u + theta*(1/rss)*rn +(1-theta)*wn );
ggn= (1/tau)*uf +yn;

/////////////////////////////
//End of the baseline, no tech model //
////////////////////////////
end;

//varobs y_g pai i c_g w_g h_g;

varobs y_g pai i c_g w_g h_g tfpe_g ;
//varobs y_g pai i c_g w_g h_g tfp_g ;

@#if tech ==1
initval;

ynobs=0;
p = 0; 
pai = 0;
u = 0;
ud= 0;
uc= 0;
uh= 0;
um= 0;

a = 0;
i=0;
lamda =0;
iv=0;
tiv=0;

v=0;


nf=0;
nfn=0;


y =0 ;
k = 0;
h = 0;
iv=0;
c = 0;
m = 0;
w =0 ;
r = 0;
rd = 0;
pf =0;
//q=0;
//eue=0;

yn =0 ;
kn = 0;
hn = 0;
cn = 0;
//mn = 0;
wn =0 ;
rn = 0;
rdn = 0;
pfn =0;
pn = 0; 
pain = 0;
an = 0;
in=0;
ivn=0; 
lamdan=0;
//qn=0;


hg=0;
yg=0;

end;

steady_state_model;

 
ynobs=0;
p = 0; 
pai = 0;
u = 0;
ud= 0;
uc= 0;
uh= 0;
um= 0;

a = 0;
i=0;
lamda =0;
tiv=0;

v=0;


nf=0;
nfn=0;


y =0 ;
k = 0;
h = 0;
iv=0;
c = 0;
m = 0;
w =0 ;
r = 0;
rd = 0;
pf =0;
//q=0;
//eue=0;

yn =0 ;
kn = 0;
hn = 0;
cn = 0;
//mn = 0;
wn =0 ;
rn = 0;
rdn = 0;
pfn =0;
pn = 0; 
pain = 0;
an = 0;
in=0;
ivn=0; 
lamdan=0;
//qn=0;


hg=0;
yg=0;

end;


 shocks;
 //var me; stderr 0.01;
 //var mee; stderr 0.01;
 var ei; stderr 0.01;
 var eu; stderr 0.01;
var ef; stderr 0.01;
 @#if news==1
  
   @#if eshock==16
   var eue4; stderr 0.01;
  
  var eue8; stderr 0.01;
  
  var eue12; stderr 0.01;
  
  var eue; stderr 0.01;
  @#endif 


  var etfp; stderr 0.0010;

  @#if eshock==20
  var eue; stderr 0.01;
  var eue1; stderr 0.01;
  var eue2; stderr 0.01;
  var eue3; stderr 0.01;
  var eue4; stderr 0.01;
  var eue5; stderr 0.01;
  var eue6; stderr 0.01;
  var eue7; stderr 0.01;
  var eue8; stderr 0.01;
  var eue9; stderr 0.01;
  var eue10; stderr 0.01;
  var eue11; stderr 0.01;
  var eue12; stderr 0.01;
  var eue13; stderr 0.01;
  var eue14; stderr 0.01;
  var eue15; stderr 0.01;
  var eue16; stderr 0.01;
  var eue17; stderr 0.01;
  var eue18; stderr 0.01;
  var eue19; stderr 0.01;
  @#endif 


 @#endif
 @#if dshock==1
 var eud; stderr 0.01;
 @#endif
 
 @#if cshock==1
 var euc; stderr 0.01;
 @#endif
 
 //var euc; stderr 0.1;
 
@#if hshock==1
 var euh; stderr 0.01;
@#endif
 //var eum; stderr 0.1;

end;

@#endif

//The begining of No tech model//
@#if tech==0
initval;

//sh=0;
prc = 0; 
pai = 0;
u = 0;
ud= 0;
uc= 0;
uh= 0;
um= 0;


i=0;
lamda =0;
iv=0;


v=0;



y =0 ;
k = 0;
h = 0;
iv=0;
c = 0;
m = 0;
w =0 ;
r = 0;

//q=0;
//eue=0;

yn =0 ;
kn = 0;
hn = 0;
cn = 0;
//mn = 0;
wn =0 ;
rn = 0;
//rdn = 0;

pn = 0; 
pain = 0;

in=0;
ivn=0; 
lamdan=0;
//qn=0;


hg=0;
yg=0;

end;

steady_state_model;
p = 0; 
pai = 0;
u = 0;
ud= 0;
uc= 0;
uh= 0;
um= 0;


i=0;
lamda =0;
//tiv=0;

v=0;




y =0 ;
k = 0;
h = 0;
iv=0;
c = 0;
m = 0;
w =0 ;
r = 0;

//q=0;
//eue=0;

yn =0 ;
kn = 0;
hn = 0;
cn = 0;
//mn = 0;
wn =0 ;
rn = 0;

//pfn =0;
pn = 0; 
pain = 0;

in=0;
ivn=0; 
lamdan=0;
//qn=0;


hg=0;
yg=0;

end;


 shocks;

//var me; stderr 0.01;
 //var mee; stderr 0.01;
 var ei; stderr 0.01;
 var eu; stderr 0.01;
 var ef; stderr 0.01;
 @#if news==1
  
  
  @#if eshock==16
   var eue4; stderr 0.01;
  
  var eue8; stderr 0.01;
  
  var eue12; stderr 0.01;
  
  var eue; stderr 0.01;
  @#endif 

  var etfp; stderr 0.0010;

  @#if eshock==20
  var eue; stderr 0.01;
  var eue1; stderr 0.01;
  var eue2; stderr 0.01;
  var eue3; stderr 0.01;
  var eue4; stderr 0.01;
  var eue5; stderr 0.01;
  var eue6; stderr 0.01;
  var eue7; stderr 0.01;
  var eue8; stderr 0.01;
  var eue9; stderr 0.01;
  var eue10; stderr 0.01;
  var eue11; stderr 0.01;
  var eue12; stderr 0.01;
  var eue13; stderr 0.01;
  var eue14; stderr 0.01;
  var eue15; stderr 0.01;
  var eue16; stderr 0.01;
  var eue17; stderr 0.01;
  var eue18; stderr 0.01;
  var eue19; stderr 0.01;
  @#endif 


  
 @#endif

 @#if dshock==1
 var eud; stderr 0.01;
 @#endif
 
 @#if cshock==1
 var euc; stderr 0.01;
 @#endif
 
 //var euc; stderr 0.1;
 
@#if hshock==1
 var euh; stderr 0.01;
@#endif
 //var eum; stderr 0.1;

end;

@#endif
/// End of No tech model///////


estimated_params;

//index,0.3291,0.00001,0.99999,BETA_PDF,0.5,0.25;

xxx,,0.0001,0.9999, beta_pdf, 0.75, 0.1;
xpai,1.7985,0.0001,, normal_pdf, 1.5, 0.25;
xy,0.0893,0.0001,,normal_pdf, 0.125,0.05; 

hb,0.4205,0.0001,0.9999,BETA_PDF,0.7,0.1;
rho,0.7813,0.0001,0.9999,BETA_PDF,0.5,0.1;
//sigh,1,0.0001,,normal_pdf, 2, 0.75;
sigc,1,0.0001,,normal_pdf, 1.50, 0.375;
//sigm,3,0.0001,,normal_pdf, 2.56, 0.5;
ss,7,0.0001,,normal_pdf, 4, 1.5;

phi,4,1.5000,,normal_pdf, 6, 0.9;

rhou,0.5,0.0001,0.9999,beta_pdf, 0.5, 0.2;
rhoi,0.5,0.0001,0.9999,beta_pdf, 0.5, 0.2;
@#if dshock==1
rhoud,0.5,0.0001,0.9999, beta_pdf, 0.5, 0.2;
@#endif

@#if hshock==1
rhouh,0.5,0.0001,0.9999, beta_pdf, 0.5, 0.2;
@#endif

@#if cshock==1
rhouc,0.5,0.0001,0.9999, beta_pdf, 0.5, 0.2;
@#endif 

rhouf,0.5,0.0001,0.9999,beta_pdf, 0.5, 0.2;



stderr eu,0.1,,,inv_gamma_pdf, 0.008, inf; 
stderr ei,0.1,,,inv_gamma_pdf, 0.003, inf;
@#if cshock==1
stderr euc,0.1,,, inv_gamma_pdf, 0.01, inf;
@#endif
@#if hshock==1
stderr euh,0.1,,,inv_gamma_pdf, 0.01, inf;
@#endif
@#if dshock==1
stderr eud,0.1,,,inv_gamma_pdf, 0.01, inf;
@#endif

stderr ef,0.1,,,inv_gamma_pdf, 0.01, inf;


//stderr tfp_g,0.1,,,inv_gamma_pdf, 0.01, inf;
//stderr k_g,0.1,,,inv_gamma_pdf, 0.005, inf;


@#if news==1


@#if eshock==16
 stderr eue4,0.1,,,inv_gamma_pdf,0.004, inf;
 stderr eue8,0.1,,,inv_gamma_pdf,  0.004, inf;
 stderr eue12,0.1,,,inv_gamma_pdf,  0.004, inf;
 stderr eue,0.1,,,inv_gamma_pdf,  0.004, inf;

//stderr etfp,0.1,0,,normal_pdf, 0.002, 0.0002;
stderr etfp,0.1,0,,gamma_pdf, 0.0016, 0.0003;


corr eue4, eue8, 0.74, , ,beta_pdf, 0.0, 0.45, -1, 1;
corr eue4, eue12, 0.54, , ,beta_pdf, 0.0, 0.45, -1, 1;
corr eue4, eue, 0.540, , ,beta_pdf, 0.0, 0.45, -1, 1;
//corr eue4, eu, 0.3705, , ,beta_pdf, 0.0, 0.45, -1, 1;

corr eue8, eue12, 0.704, , ,beta_pdf, 0.0, 0.45, -1, 1;
corr eue8, eue, 0.45, , ,beta_pdf, 0.0, 0.45, -1, 1;
//corr eue8, eu, -0.6327, , ,beta_pdf, 0.0, 0.45, -1, 1;

corr eue12, eue, 0.14, , ,beta_pdf, 0.0, 0.45, -1, 1;
//corr eue12, eu, -0.5500, , ,beta_pdf, 0.0, 0.45, -1, 1;

//corr eue, eu, 0.1995, , ,uniform_pdf, , ,-1,1;


@#endif

@#endif


end;

estimated_params_init;
//index, 0.324;


xxx, 0.58072535052;//* 0.8
xpai, 0.9291084698058;//*1.5596;
xy, 0.3117123132040;//*0.1005; 
hb,0.915768639;//*0.5006
rho,0.7373576;
sigh, 2.00;//*1.9;
sigc,0.971260000;//*1.9904;
sigm,2.56;
ss, 7.395200;//*4.23;
phi, 6.08579157;//*4.2783;

rhou,0.91357;
rhoi,0.37574324640;//*0.2081;//*0.4940;
rhouc,0.00100152015030896058;//*0.5981;//*0.7188;
rhoud,0.5578500;//*0.5981;//*0.7188;
rhouh,0.98559;//*0.3039;
rhouf,0.985728621;//*0.3039;


//xxx, 0.5872535052;//* 0.8
//xpai, 0.84698058;//*1.5596;
//xy, 0.27123132040;//*0.1005; 
//hb,0.88639;//*0.5006
//rho,0.73576;
//sigh, 2.00;//*1.9;
//sigc,1.60000;//*1.9904;
//sigm,2.56;
//ss, 0.5200;//*4.23;
//phi, 3.79157;//*4.2783;
//rhou,0.99357;
//rhoi,0.4324640;//*0.2081;//*0.4940;
//rhouc,0.0015030896058;//*0.5981;//*0.7188;
//rhoud,0.5578500;//*0.5981;//*0.7188;
//rhouh,0.9559;//*0.3039;
//rhouf,0.928621;//*0.3039;

@#if dshock==1
stderr eud,0.01420170;
@#endif

@#if cshock==1
stderr euc,0.0916144;
@#endif

@#if hshock==1
stderr euh,0.0158;
@#endif

stderr ef,0.005216144;

@#if news==1

 
  @#if eshock==16
  stderr eue4,  0.001934;
  stderr eue8, 0.0030318;
 stderr eue12, 0.001823;
  stderr eue,  0.0014934;
 @#endif

 stderr etfp, 0.00634;

@#endif


end;

 
 
options_.gmhmaxlik.nscale = 1000000;


//estimation(mode_compute=6, mode_file=merror_BNK_grwnoadj_noEud3_new03m_mode,optim=('NumberOfMh',3,'ncov-mh',70000,'nscale-mh',500000, 'AcceptanceRateTarget',0.25),moments_varendo, conditional_variance_decomposition = [ 4 8 12 16 20 32 40], plot_priors = 0,prior_trunc=0,bayesian_irf,irf=40, irf_shocks=(eue4,eue8,eue12,eue, eu,ei,euc, euh,ef), datafile=data_growth,prefilter=0,first_obs=1,presample=4, mh_replic=300000,mh_nblocks=2,mh_drop=0.7) y_g c_g h_g w_g pai i tfp_g tfpe_g, y prc tfp tfpe h c iv gg k w r mc  ;
estimation(mode_compute=0, mode_file=merror_BNK_grwnoadj_noEud3_new03m_mode,optim=('NumberOfMh',3,'ncov-mh',70000,'nscale-mh',500000, 'AcceptanceRateTarget',0.25),moments_varendo, conditional_variance_decomposition = [ 4 8 12 16 20 32 40], plot_priors = 0,prior_trunc=0,bayesian_irf,irf=40, irf_shocks=(eue4,eue8,eue12,eue, eu,ei,euc, euh,ef), datafile=data_growth,prefilter=0,first_obs=1,presample=4, mh_replic=300000,mh_nblocks=2,mh_drop=0.7) y_g c_g h_g w_g pai i tfp_g tfpe_g, y prc tfp tfpe h c iv gg k w r mc  ;


@#endif


